﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace WholesalerService
{
    public class MyHashtable
    {
        public static Hashtable NewHashtable(Hashtable table,bool isStringFlag=true) {
            Hashtable myTable = new Hashtable();
            //得到hashtable 的key与value对像用 DictionaryEntry
            foreach (DictionaryEntry item in table)
            {
                if (item.Value == null) continue;
                if (item.Value.GetType().ToString() != "Newtonsoft.Json.Linq.JArray")
                    myTable.Add(item.Key, item.Value);
                else
                {
                    if (isStringFlag)
                        myTable.Add(item.Key, ((Newtonsoft.Json.Linq.JArray)item.Value).ToObject<string[]>()); //ibatis.net map parameterClass="System.Collections.IDictionary" 这个能识别string[],list<T>,但是不识别Newtonsoft.Json.Linq.JArray ，所以这里强制转换下
                    else
                        myTable.Add(item.Key, ((Newtonsoft.Json.Linq.JArray)item.Value).ToObject<int[]>());
                }
            }
            return myTable;
        }
    }
}